package com.gimi.cloud.jimi.manage.common.springUtil;

import com.gimi.cloud.jimi.commonService.common.JmInitService;
import com.gimi.cloud.jimi.dao.dao.sys.SysConfigDao;
import com.gimi.cloud.jimi.dao.redis.IRedisService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;


/**
 * 初始化配置
 * Created by shazhiwei on 2017/9/6.
 */
@Component
public class InitConfig implements CommandLineRunner {

    private static Logger logger = LoggerFactory.getLogger(InitConfig.class);

    //public final static Map<String, SysConfigEntity> config = new Hashtable<>();
    //配置状态为开启
    private SysConfigDao sysConfigDao;
    private IRedisService redisService;
    private JmInitService jmInitService;

    @Autowired
    public InitConfig(SysConfigDao sysConfigDao, IRedisService redisService,
                      JmInitService jmInitService) {
        this.sysConfigDao = sysConfigDao;
        this.redisService = redisService;
        this.jmInitService = jmInitService;
    }

    @Override
    public void run(String... arg0) throws Exception {
        jmInitService.initSysConfig();//加载sys_config数据
        jmInitService.initOssClient();//初始化oss客户端
    }


	/*public static SysConfigEntity getConfigByKey(String key){
		return config.get(key);
	}*/

	/*public static String getValueByKey(String key){
		String result = null;
		SysConfigEntity configEntity = config.get(key);
		if(configEntity != null){
			String value = configEntity.getCfValue();
			if(!StringUtil.isBlank(value)){
				result = value;
				logger.info("获取配置===>" + result);
			}
		}
		return result;
	}*/

}
